<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>1_props基本使用</title>
</head>

<body>
    <div id="test1"></div>
    <div id="test2"></div>
    <div id="test3"></div>
    <script type="text/javascript" src="../js/react.development.js"></script>
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <script type="text/javascript" src="../js/babel.min.js"></script>
    <script type="text/babel">
        // 创建组件
        class Person extends React.Component {
            render() {
                console.log(this);
                return (
                    <ul>
                        <li>姓名：{this.props.name}</li>
                        <li>性别：{this.props.sex}</li>
                        <li>年龄：{+this.props.age}</li>
                    </ul>
                )
            }
        }
        const p = {
            name: 'may',
            sex: '女',
            age: 18
        }
        // 渲染组件到页面
        ReactDOM.render(<Person name="tom" sex="男" age="20" />, document.getElementById('test1'));
        ReactDOM.render(<Person name="amy" sex="女" age="19" />, document.getElementById('test2'));
        ReactDOM.render(<Person {...p} />, document.getElementById('test3')); // 批量传递标签属性
        // ReactDOM.render(<Person name="may" sex="女" age="18" />, document.getElementById('test3'));
    </script>
</body>

</html>